@extends('default.layouts.adminPublic')
@section('title', '企业用户注册')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/admin/indexList.css')}}">
    @endsection
    @section('content')
            <!--导航开始-->
    <div class="crumb_warp">
        <i class="fa fa-home"></i> <a href="{{url('admin/com_user_reg')}}">首页</a> &raquo; 用户管理
    </div>
    <!--导航结束-->
    <!--结果集标题与导航组件 开始-->

    <div class="con">
        <div class="conMain">


            <div class="result_wrap" style="height:140px;">
                <div class="search">
                    <form name="Formso" id="Formso" action="{{url('admin/com_user_reg')}}" method="post">
                        {{csrf_field()}}
                        <span>关键字：</span>
                        <span><input name="keyword" class="keyword" id="keyword" placeholder="请输入用户名或者手机号码或公司名称"
                                     type="text"></span>
                        <span><input name="submit" class="skeyword" value="搜索" type="submit"></span>
                    </form>
                    <div class="smart">
                        <ul>
                            <li class="title">会员类型：</li>
                            <li><a href="{{url('admin/com_user_reg?vip=yes')}}">会员</a></li>
                            <li><a href="{{url('admin/com_user_reg?vip=mVip')}}">到期会员</a></li>
                            <li><a href="{{url('admin/com_user_reg?vip=no')}}">非会员</a></li>
                        </ul>
                        <div class="message"><p>目前共查找到<strong>{{$user->total()}}</strong>个用户！且每页显示用户{{$user->perPage()}}
                                个用户。</p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="manage">
                @include('flash::message')
            </div>
            <div class="conInfo">
                <form name="thisForm" id="thisForm" action="" method="post">
                    {{csrf_field()}}
                    <div class="conList" id="conList">
                        <dl class="one">
                            <dt><input name="selectall" type="checkbox" value="1" onclick="CheckAll(this)"/></dt>
                            <dd class="pc1">用户ID</dd>
                            <dd class="pc2">用户名</dd>
                            <dd class="pc3">公司名称</dd>
                            <dd class="pc4">手机号码</dd>
                            <dd class="pc5">注册时间</dd>
                            <dd class="pc6">会员期限</dd>
                            <dd class="pc7">操作</dd>
                        </dl>
                        @if($user->count() > 0 )
                            @foreach($user as $v)
                                <dl id="list{{$v->uid}}">
                                    <dt><input name="selected_id[]" type="checkbox" value="{{$v->uid}}"/></dt>
                                    <dd class="pc1">{{$v->uid}}</dd>
                                    <dd class="pc2">{{str_limit($v->username,20)}}</dd>
                                    <dd class="pc3"><a href="{{url('admin/go_com_about?uid='.$v->uid)}}"
                                                       target="_blank">{{str_limit($v->company_name,28)}}</a></dd>
                                    <dd class="pc4">{{$v->mobile}}</dd>
                                    <dd class="pc5">{{$v->regtime}}</dd>
                                    <dd class="pc6">
                                        @if($v->viptime > date('Y-m-d H:i:s',time()))
                                            <span style="color: #ff4400;">{{$v->viptime}}</span>
                                            @if($v->stop_number>0)
                                                <b>{{$v->stop_number}}</b>
                                            @endif
                                        @else
                                            {{$v->viptime}}
                                        @endif
                                    </dd>
                                    <dd class="pc7">
                                        <span><a href="{{url('admin/contract/'.$v->uid)}}">签合同</a></span>
                                        <span><a href="{{url('admin/company_welcome/'.$v->uid)}}"
                                                 target="_blank">账户中心</a></span>
                                        <span><a href="{{url('admin/com_user_mod/'.$v->uid)}}">注册信息</a></span>
                                        <span class="del"><a>删除</a></span>
                                    </dd>
                                </dl>
                            @endforeach
                        @else
                            <div class="nullcon">对不起！没有符合条件的记录！</div>
                        @endif
                        <dl class="last">
                            <dt>
                                <input name="selectall" id="selectall" type="checkbox" value="1"
                                       onclick="CheckAll(this)"/>
                                <label for="selectall">全选</label>
                            </dt>
                        </dl>
                    </div>
                </form>
                <div class="page_list" style="width: 100%; float: left; margin-top:15px;">
                    {!! $user->appends($input)->links() !!}
                </div>
            </div>

            <div class="stopper" style="margin-top:10px; border-top: 1px solid #e5e5e5"></div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
@endsection

@section('footerjs')
    @parent
    <script>
        //全选中与全不选中职位资料
        function CheckAll(form){
            if(form.checked == true){
                for(var i = 0; i < document.thisForm.elements.length; i++){
                    var e = document.thisForm.elements[i];
                    if(e.name == 'selectedid' || e.name == 'selected_id[]' || e.name == 'selectall')
                        e.checked = true;
                }
            }else{
                for(var i = 0; i < document.thisForm.elements.length; i++){
                    var e = document.thisForm.elements[i];
                    if(e.name == 'selectedid' || e.name == 'selected_id[]' || e.name == 'selectall')
                        e.checked = false;
                }
            }
        }
        $(function(){

        });
    </script>
    <script>
        //删除当前
        @if($user->count() > 0 )
            @foreach($user as $v)
                $('#conList').find("#list" + '{{$v->uid}}').find('.del a').click(function(){
            layer.confirm('确定要删除该用户所有数据吗？', {
                btn: ['确定', '取消'] //按钮
            }, function(){
                $.get("/admin/com_user_del/" + '{{$v->uid}}', {'_token': "{{csrf_token()}}"}, function(data){
                    if(data.status == 0){
                        $('#conList').find("#list" + '{{$v->uid}}').remove();
                        layer.msg(data.msg, {icon: 6, time: 1500});
                    }else{
                        layer.msg(data.msg, {icon: 5, time: 1500});
                    }
                });
            });
        });
        @endforeach
        @endif
    </script>
@endsection